local skel = fk.CreateSkill{
  name = "tea__qiwei",
}
Fk:loadTranslationTable{
  ["tea__qiwei"] = "绮位",
  [":tea__qiwei"] = "出牌阶段限一次，你可以与一名角色拼点，赢的角色获得所有拼点牌，然后另一名角色摸X张牌（X为此次拼点牌中没有的花色数）。",
}
---@type ActiveSkillSpec
local qiwei = {
  anim_type = "drawcard",
  card_filter = Util.FalseFunc,
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  target_num = 1,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and player:canPindian(to_select)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local pindian = player:pindian({ target }, skel.name)
    local winner = pindian.results[target].winner
    if winner and not winner.dead then
      room:delay(1000)
      local cards = { pindian.fromCard, pindian.results[target].toCard }
      cards = table.filter(cards, function (c)
        return table.contains({ Card.DiscardPile, Card.Processing, Card.DrawPile }, room:getCardArea(c))
      end)
      if #cards > 0 then
        room:obtainCard(winner, cards, true, fk.ReasonJustMove, winner, skel.name)
      end
      local losers = { player, target }
      table.removeOne(losers, winner)
      if #losers == 1 then
        local loser = losers[1]
        local suits = {}
        for _, c in ipairs({ pindian.fromCard, pindian.results[target].toCard }) do
          table.insertIfNeed(suits, c.suit)
        end
        if #suits > 0 and #suits < 4 then
          loser:drawCards(4 - #suits, skel.name)
        end
      end
    end
  end,
}
skel:addEffect("active", qiwei)
return skel